/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package polindroms;

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author root
 */

public class Polindroms {
    static Scanner in = new Scanner(System.in);
    
    public static void main(String[] args){
        String inpString = input();
        ArrayList<String[]> polindroms = findPolindroms(inpString);
        outPut(polindroms);
    }
    /**
     * Method to input the string
     * @return string
     */
    private static String input(){
        System.out.println("Your string, please.");
        String string = in.nextLine();
        return string;
    }
    /**
     * Method to reverse inputed string into ArrayList<String[]>
     * @param string
     * @return ArrayList<String[]>
     */
    private static ArrayList<String[]> toArray(String string){
        String[] stringArr = string.split(" ");
        ArrayList<String[]> res = new ArrayList<String[]>();
        for(int i = 0; i < stringArr.length; i++){
            res.add(stringArr[i].split(""));
        }
        return res;
    }
    /**
     * Method to check is a substring a polindrom
     * @param string
     * @return boolean
     */
    private static boolean isPolindrom(String[] string){
        for(int i = 1; i < string.length; i++){
           
            if(!string[i].equals(string[string.length -i])){
                return false;
            }
        }
        return true;
    }
    /**
     * Method to find polindroms in the string
     * @param string
     * @return ArrayList<String[]> arrayList of polindroms
     */
    private static ArrayList<String[]> findPolindroms (String s){
        ArrayList<String[]> string = toArray(s);
        ArrayList<String[]> res = new ArrayList<String[]>();
        
        for(int i = 0; i < string.size(); i++){
            
            
            
            if(isPolindrom(string.get(i))){
                res.add(string.get(i));
                
            }
        }
        return res;
    }
    /**
     * Method to output polindroms array
     * @param ArrayList<integer> string 
     */
    private static void outPut(ArrayList<String[]> polindroms){
        System.out.print("Polindroms : ");
        for(int i = 0; i < polindroms.size(); i++){
            for(int j = 0; j < polindroms.get(i).length; j++){
                System.out.print(polindroms.get(i)[j]);
            }
            System.out.print(", ");
        }
                
    }
}
